package main

import "fmt"

func main() {
	//test1()
	//test2()
	//test3()
	//test4()
	//test5()
	//test6()
	test7()
}

func test1() {
	a := [...]int{1, 2, 3, 4, 5}

	for i := 0; i < len(a); i++ {
		fmt.Printf("a[%v] = %v\n", i, a[i])
	}
}

func test2() {
	a := [...]int{1, 2, 3, 4, 5}
	for index, value := range a {
		fmt.Printf("a[%v] = %v\n", value, a[index])
	}
}

func test3() {
	var a [2][2]int
	a[0][0] = 1
	a[0][1] = 2
	a[1][0] = 3
	a[1][1] = 4
	//fmt.Printf("a = %v\n", a)

	for _, value := range a {
		//fmt.Println(index, value)
		for key, item := range value {
			fmt.Println(key, item)
		}
	}
}

func test4() {
	//var arr = [2][3]string{{"1", "3", "3"}, {"7", "5", "6"}}
	arr := [2][3]string{{"1", "3", "3"}, {"7", "5", "6"}}
	fmt.Printf("arr = %v\n", arr)
}

func test5() {
	a := [3]int{1, 2, 3}
	fmt.Println(a)

}
func modify(b [3]int) {
	b[0] = 1000
}

func test6() {
	a := [10]int{
		1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
	}
	sum := sumArray(a)
	fmt.Printf("sum = %v\n", sum)
}

//求数组中所有元素之和
func sumArray(a [10]int) int {
	sum := 0
	for _, value := range a {
		sum += value
	}
	return sum
}

func test7() {
	a := [5]int{1, 3, 5, 8, 7}
	example(a)
}
func example(a [5]int) {
	sum := 8
	for _key, value := range a {
		var c = sum - value
		for _item, item := range a {
			if item == c {
				fmt.Printf("%v,%v\n", _item, _key)
			}
		}
	}
}
